package com.ss.android.article.browser.search.b;

import android.app.Application;
import android.support.annotation.NonNull;
import com.ss.android.article.browser.c.d;
import com.ss.android.article.browser.database.BrowserHistory;

import java.io.InputStream;
import java.util.List;
import org.json.JSONArray;

public final class a extends b {
    @NonNull private final String a;

    public a(@NonNull Application arg2) {
        super(arg2, "UTF-8");
        this.a = arg2.getString(com.ss.android.article.browser.R.string.yu);
    }

    @NonNull protected final String a(@NonNull String arg3) {
        return "http://suggestion.baidu.com/s?wd=" + arg3 + "&action=opensearch";
    }

    protected final void a(@NonNull InputStream arg10, @NonNull List arg11) throws Exception {
        JSONArray v3 = new JSONArray(d.readInputStream(arg10, "GBK")).getJSONArray(1);
        int v4 = v3.length();
        int v0 = 0;
        int v2 = 0;
        while(v0 < v4) {
            String v5 = v3.getString(v0);
            arg11.add(new BrowserHistory(this.a + " \"" + v5 + '\"', v5, (byte) 0));
            ++v2;
            if(v2 >= 5) {
                return;
            }

            ++v0;
        }
    }
}

